package data.email;

import data.TokenCounter;

/**
 * Token counter menyimpan jumlah token setiap label yang ada dalam dokumen
 * @author Robert Gunawan
 */
public class EmailTokenCounter extends TokenCounter {

    public Long getToBodyField() {
        return toBodyField;
    }

    public Long getToDateField() {
        return toDateField;
    }

    public Long getToFromField() {
        return toFromField;
    }

    public Long getToSubjectField() {
        return toSubjectField;
    }

    public Long getToToField() {
        return toToField;
    }

    public Long getToUnionField() {
        return toUnionField;
    }
    // term occurence dalam setiap field disimpan sebagai atribut berbeda
    private Long toToField = new Long(0);
    private Long toFromField = new Long(0);
    private Long toDateField = new Long(0);
    private Long toBodyField = new Long(0);
    private Long toSubjectField = new Long(0);
    private Long toUnionField = new Long(0);

    public void incToCounter() {
        toToField++;
        toUnionField++;
    }

    public void incFromCounter() {
        toFromField++;
        toUnionField++;
    }

    public void incDateCounter() {
        toDateField++;
        toUnionField++;
    }

    public void incBodyCounter() {
        toBodyField++;
        toUnionField++;
    }

    public void incSubjectCounter() {
        toSubjectField++;
        toUnionField++;
    }

    public void incUnionCounter() {
        toUnionField++;
        toUnionField++;
    }

    public EmailTokenCounter() {
    }

    @Override
    public void merge(TokenCounter anotherCounter) {
        EmailTokenCounter counter = (EmailTokenCounter) anotherCounter;
        this.toBodyField += counter.toBodyField;
        this.toDateField += counter.toDateField;
        this.toFromField += counter.toFromField;
        this.toSubjectField += counter.toSubjectField;
        this.toToField += counter.toToField;
        this.toUnionField += counter.toUnionField;
    }
}
